a=10
def test():
    global a  # global关键字声明使用全局变量
    a+=1
test()
print(a)

def outer():
    num = 10
    def inner():
        nonlocal num   # nonlocal关键字声明
        num = 100
        print(num)
    inner()
    print(num)
outer()

